package com.spzx.product.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.RemoteCategoryService;
import com.spzx.product.api.domain.CategoryVo;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * ClassName: RemoteCategoryFallbackFactory
 * Package: com.spzx.product.api.factory
 * Description: 文件服务降级处理
 *
 * @Author ycy
 * @Create 2024/8/9 15:52
 * @Version 1.0
 */
@Component
public class RemoteCategoryFallbackFactory implements FallbackFactory<RemoteCategoryService> {



    @Override
    public RemoteCategoryService create(Throwable cause) {

        return new RemoteCategoryService() {
            @Override
            public R<List<CategoryVo>> getOneCategory(String source) {
                System.out.println("RemoteCategoryService.getOneCategory接口异常:" + cause.getMessage());
                return R.fail(cause.getMessage());
            }

            @Override
            public R<List<CategoryVo>> tree(String source) {
                System.out.println("RemoteCategoryService,tree接口异常:"+cause.getMessage());
                return R.fail("获取全部分类失败:" + cause.getMessage());
            }
        };
    }


}
